<?php

return [
    'module' => [
        'name' => 'promotion',
        'title' => '促销活动',
        'table' => 'promotions',
    ],
    
    'fields' => [
        'id' => [
            'type' => 'bigint',
            'length' => 20,
            'comment' => '促销活动ID',
            'unsigned' => true,
            'nullable' => false,
            'primary' => true,
            'auto_increment' => true,
            'required' => true,
        ],
        'name' => [
            'type' => 'varchar',
            'length' => 64,
            'comment' => '活动名称',
            'nullable' => false,
            'required' => true,
        ],
        'type' => [
            'type' => 'tinyint',
            'length' => 4,
            'comment' => '活动类型：1限时特价，2满减活动，3套餐搭配',
            'nullable' => false,
            'required' => true,
            'default' => 1,
        ],
        'start_time' => [
            'type' => 'timestamp',
            'comment' => '开始时间',
            'nullable' => false,
            'required' => true,
        ],
        'end_time' => [
            'type' => 'timestamp',
            'comment' => '结束时间',
            'nullable' => false,
            'required' => true,
        ],
        'status' => [
            'type' => 'tinyint',
            'length' => 4,
            'comment' => '状态：0禁用，1启用',
            'nullable' => false,
            'required' => true,
            'default' => 1,
        ],
        'description' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '活动描述',
            'nullable' => false,
            'default' => '',
        ],
        'rules' => [
            'type' => 'json',
            'comment' => '活动规则',
            'nullable' => false,
            'default' => '[]',
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
        ],
        'updated_at' => [
            'type' => 'timestamp',
            'comment' => '更新时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
            'extra' => 'ON UPDATE CURRENT_TIMESTAMP',
        ],
    ],
    
    'relations' => [
        'items' => [
            'type' => 'hasMany',
            'model' => 'PromotionItem',
            'foreign_key' => 'promotion_id',
        ],
    ],
    
    'queries' => [
        'name' => ['like', '%?%'],
        'type' => ['=', '?'],
        'status' => ['=', '?'],
        'start_time' => ['between', '?,?'],
        'end_time' => ['between', '?,?'],
        'created_at' => ['between', '?,?'],
    ],
]; 